//
//  StatusCellBottomView.swift
//  SinaWeiBo
//
//  Created by dengchen on 15/11/15.
//  Copyright © 2015年 name. All rights reserved.
//

import UIKit

private let lineWidth:CGFloat = 0.5
private let lineGrayColor = UIColor(white: 0.85, alpha: 1)

class StatusCellBottomView: UIView {

   
    
    @objc private func retweetBtnTouch() {
        
        self.navigationController()?.pushViewController(TestViewController(), animated: true)
        
    }
    
    
    private func setupUI() {
        retweetBtn.addTarget(self, action: "retweetBtnTouch", forControlEvents: .TouchUpInside)
        
        
        leftLine.backgroundColor = lineGrayColor
        rightLine.backgroundColor = lineGrayColor
        topLine.backgroundColor = lineGrayColor
        
        addSubview(retweetBtn)
        addSubview(commentBtn)
        addSubview(likeBtn)

        addSubview(topLine)
        addSubview(bottomLine)
        addSubview(leftLine)
        addSubview(rightLine)
        
        
        retweetBtn.snp_makeConstraints { (make) -> Void in
            make.top.left.equalTo(self)
            make.height.equalTo(40)
        }
        
        leftLine.snp_makeConstraints { (make) -> Void in
            make.centerX.equalTo(retweetBtn.snp_right)
            make.centerY.equalTo(retweetBtn)
            make.width.equalTo(lineWidth)
            make.height.equalTo(retweetBtn).multipliedBy(0.4)
        }
        
        commentBtn.snp_makeConstraints { (make) -> Void in
            make.top.height.equalTo(retweetBtn)
            make.left.equalTo(retweetBtn.snp_right)
            make.width.equalTo(retweetBtn)
        }
        
        rightLine.snp_makeConstraints { (make) -> Void in
            make.centerX.equalTo(commentBtn.snp_right)
            make.centerY.equalTo(retweetBtn)
            make.width.equalTo(lineWidth)
            make.height.equalTo(retweetBtn).multipliedBy(0.4)
        }
        
        likeBtn.snp_makeConstraints { (make) -> Void in
            make.top.right.equalTo(self)
            make.left.equalTo(commentBtn.snp_right)
            make.width.height.equalTo(commentBtn)
        }
        
        topLine.snp_makeConstraints { (make) -> Void in
            make.left.top.right.equalTo(self)
            make.height.equalTo(lineWidth)
        }
        
        bottomLine.snp_makeConstraints { (make) -> Void in
            make.left.right.equalTo(self)
            make.top.equalTo(commentBtn.snp_bottom)
            make.height.equalTo(11)
        }
        
        
        self.snp_makeConstraints { (make) -> Void in
            make.bottom.equalTo(bottomLine)
        }
        
    }
    
    init () {
        super.init(frame: CGRectZero)
        setupUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    
    private let leftLine = UIView()

    private let rightLine = UIView()
    
    private let topLine = UIView()
    
    private let bottomLine = bottomView()
    
    private let retweetBtn:UIButton = UIButton(title: "转发", bgImge: nil, titleColor: UIColor.lightGrayColor(), image: "timeline_icon_retweet")

    
    private let commentBtn:UIButton = UIButton(title: "评论", bgImge: nil, titleColor: UIColor.lightGrayColor(), image: "timeline_icon_comment")
 
    
    private let likeBtn:UIButton = UIButton(title: "赞", bgImge: nil, titleColor: UIColor.lightGrayColor(), image: "timeline_icon_unlike")
    
}

private class bottomView: UIView {
    
    
    init() {
        super.init(frame: CGRectZero)
        setupUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    private func setupUI() {
        backgroundColor = UIColor(white: 0.95, alpha: 1)
        topline.backgroundColor = lineGrayColor
        bottomline.backgroundColor = lineGrayColor
        
        addSubview(topline)
        addSubview(bottomline)
        
        topline.snp_makeConstraints { (make) -> Void in
            make.left.right.equalTo(self)
            make.bottom.equalTo(self.snp_top)
            make.height.equalTo(lineWidth)
        }
        
        bottomline.snp_makeConstraints { (make) -> Void in
            make.left.right.equalTo(self)
            make.top.equalTo(self.snp_bottom)
            make.height.equalTo(lineWidth)
        }
        
    }
    
    private let topline = UIView()
    
    private let bottomline = UIView()
    
}
